package com.ylr.base.common.vo;

import com.ylr.base.common.constant.Constant;
import com.ylr.base.common.jsr303.annotation.StringEnum;
import com.ylr.base.common.jsr303.group.OrderSearch;
import com.ylr.base.common.jsr303.group.Search;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wei
 * date: 2021-05-14 11:29:00
 * className: BaseVo 公共Vo类
 * version: 1.0
 * description:
 */
@Setter
@Getter
public class BaseVo {

    /**
     * 查询-检索内容
     */
    protected String word;

    /**
     * 查询-状态
     */
    protected Integer status;

    /**
     * 查询-页码
     */
    @NotNull(message = "页码不能为空", groups = { Search.class, OrderSearch.class })
    @Range(message = "页码不能超于500页", max = 500, groups = { Search.class, OrderSearch.class })
    protected Integer pageNo;

    /**
     * 查询-一页显示数据个数
     */
    @NotNull(message = "每页大小不能为空", groups = { Search.class, OrderSearch.class })
    @Range(message = "每页大小不能超于1000", max = 1000, groups = { Search.class, OrderSearch.class })
    protected Integer pageSize;

    /**
     * 数据排序字段
     */
    @NotNull(message = "排序字段不能为空", groups = { OrderSearch.class })
    protected String field;

    /**
     * 数据排序方式[ascending-升序 descending-降序]
     */
    @NotNull(message = "排序方式不能为空", groups = { OrderSearch.class })
    @StringEnum(message = "排序方式值错误", enumValues = { Constant.ASCENDING, Constant.DESCENDING }, groups = { OrderSearch.class })
    protected String order;

}
